package perf.graph;

import java.io.File;

import perf.data.Sourcefile;

public class VertexSourcefile extends Vertex {

	private Sourcefile sfile;
	private VertexBinary parent;
	
	public VertexSourcefile( Sourcefile sf, VertexBinary parent ) {
		this.sfile = sf;
		this.parent = parent;
	}
	
	@Override
	public String getLabel() {
		return (new File(sfile.getName())).getName();
	}

	@Override
	public String getPath() {
		String s = (new File( sfile.getName())).getParent(); 
		if ( s != null ) {
			return s;
		} else {
			return "";
		}
	}
	
	public float getCostPercent( ) {
		//TODO hardcoded index
		return sfile.getCost(0) / parent.getParent().getTotalCost();
	}

}
